package summer;

import java.awt.BorderLayout;
import java.awt.TextArea;
import java.util.LinkedList;
import java.util.List;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class ChatWindow extends JFrame {

    private static final long serialVersionUID = 1L;
    private String creator;

    public void addMessageToPanel(String sendor, long time, String content) {

        //Message message = new Message();

    }
    // 定义组件
    // 历史消息展示
    List<Message> messages = new LinkedList<Message>();
    JPanel messagesDisplayPanel = new JPanel();

    // 消息编辑框和发送按钮
    // 4行 每行30个字符
    TextArea messageEditor = new TextArea(3, 40);
    JButton messageSendButton = new JButton("发送");
    JPanel messageEditPanel = new JPanel();

    public static void main(String[] args) throws Exception {
        new ChatWindow();
    }


    public ChatWindow() {

        this.messageEditPanel.add(this.messageEditor);
        this.messageEditPanel.add(this.messageSendButton);
        this.add(this.messageEditPanel, BorderLayout.SOUTH);

        this.add(this.messagesDisplayPanel, BorderLayout.CENTER);

        this.setTitle("聊天室");
        this.setSize(400, 600);
        this.setLocation(200, 200);
        this.setVisible(true);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

}